package com.wg.wuge.study.designmodel.tulingxueyuan;

/**
 * 建造者模式
 */
public class BuilderDesign {

    public static void main(String[] args) {
        Builder builder = new Builder().companyName("ss").productName("sss").part1("xxx");
        System.out.println(builder.builder());
    }
    static class Builder {
        private String companyName;
        private String productName;
        private String part1;
        private String part2;

        Builder companyName(String companyName) {
            this.companyName = companyName;
            return this;
        }
        Builder productName(String productName) {
            this.productName = productName;
            return this;
        }
        Builder part1(String part1) {
            this.part1 = part1;
            return this;
        }
        Builder part2(String part2) {
            this.part2 = part2;
            return this;
        }

        Products builder() {
            return new Products(this.companyName, this.productName, this.part1, this.part2);
        }

    }

}

class Products{
    private String companyName;
    private String productName;
    private String part1;
    private String part2;

    public Products(String companyName, String productName, String part1, String part2) {
        this.productName = productName;
        this.part1 = part1;
        this.companyName = companyName;
        this.part2 = part2;
    }

}
